package twoD.hofem;

/**
 * A basis for polynomials of degree p where the basis functions are simply the
 * monomials up to p.
 * 
 * @author Matthias Baitsch
 */
public class MonomialFB extends AbstractPolynomialBasisOnR {

	/**
	 * Constructs a monomial basis of degree 2.
	 */
	public MonomialFB() {
		setP(2);
	}

	/**
	 * Constructs a monomial basis of the specified degree.
	 * 
	 * @param p
	 *            polynomial degree
	 */
	public MonomialFB(int p) {
		setP(p);
	}

	@Override
	public FunctionRToR[] createBasis(int p) {
		FunctionRToR[] shapeFunctions = new FunctionRToR[p + 1];

		shapeFunctions = new FunctionRToR[p + 1];
		for (int i = 0; i < p + 1; i++) {
			double[] coeffs = new double[p + 1];
			coeffs[i] = 1;
			shapeFunctions[i] = new PolynomialRToR(-1, 1, coeffs);
		}
		return shapeFunctions;
	}

	public Interval getDomain() {
		return new Interval(-1, 1);
	}

	@Override
	public String getName() {
		return "Monomials";
	}
}
